package com.zatech.cgnci.project.base.result;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import java.io.Serializable;


/**
 * @author edy
 */
@Data
public class PageQueryDTO implements Serializable {

    private static final long serialVersionUID = 852655710784322244L;

//    @NotNull(message = "页码不能为空")
    @Min(value = 1, message = "页码不能小于1")
    @Max(value = 10000, message = "页码不能大于10000")
    @ApiModelProperty(value = "页码", required = true)
    private Integer page = 1;

//    @NotNull(message = "请求行数不能为空")
    @Min(value = 1, message = "请求行数最小值1")
    @Max(value = 200, message = "请求行数最大值200")
    @ApiModelProperty(value = "请求行数", required = true)
    private Integer row = 10;

    /**
     * 设置分页查询信息
     *
     * @param page   页数
     * @param row 数据个数
     */
    public void setPageInfo(int page, int row) {
        this.page = page;
        this.row = row;
    }

    /**
     * 转分页参数
     *
     * @return 分页数据
     */
    public Page toPage() {
        return new Page(page, row);
    }


}
